home *** CD-ROM | disk | FTP | other *** search
/ Kellogg's Amérique / Kellogg's Amérique / super_quizz.swf / scripts / jeux / SuperQuiz.as < prev   
Text File  |  2020-08-04  |  5KB  |  173 lines

  1. package jeux
  2. {
  3.    import flash.display.MovieClip;
  4.    import flash.events.MouseEvent;
  5.    import flash.events.TimerEvent;
  6.    import flash.text.TextField;
  7.    import flash.utils.Timer;
  8.    
  9.    public class SuperQuiz extends Jeu
  10.    {
  11.        
  12.       
  13.       public var mascotte:MovieClip;
  14.       
  15.       public var current_question:int;
  16.       
  17.       public var quizz2:MovieClip;
  18.       
  19.       public var quizz5:MovieClip;
  20.       
  21.       public var quizz7:MovieClip;
  22.       
  23.       public var quizz8:MovieClip;
  24.       
  25.       public var quizz9:MovieClip;
  26.       
  27.       public var quizz4:MovieClip;
  28.       
  29.       public var quizz6:MovieClip;
  30.       
  31.       public var quizz3:MovieClip;
  32.       
  33.       public var chargement:MovieClip;
  34.       
  35.       public var quizz1:MovieClip;
  36.       
  37.       public var bonne:Boolean;
  38.       
  39.       public var score:Score;
  40.       
  41.       public var quizz10:MovieClip;
  42.       
  43.       public var timer_question:Timer;
  44.       
  45.       public var n_page:TextField;
  46.       
  47.       public var secondechance:Boolean = false;
  48.       
  49.       public var page_resultat:MovieClip;
  50.       
  51.       public function SuperQuiz()
  52.       {
  53.          secondechance = false;
  54.          timer_question = new Timer(2500,1);
  55.          super();
  56.          pages = [chargement,quizz1,quizz2,quizz3,quizz4,quizz5,quizz6,quizz7,quizz8,quizz9,quizz10,page_resultat];
  57.          jouer();
  58.          page_resultat.btn_jouer.addEventListener(MouseEvent.CLICK,clic_bouton);
  59.          mascotte.gotoAndStop(1);
  60.          n_page.text = "1";
  61.       }
  62.       
  63.       override public function toString() : String
  64.       {
  65.          return "SuperQuiz";
  66.       }
  67.       
  68.       override public function quitter() : *
  69.       {
  70.          current_question = 0;
  71.          score.score = 0;
  72.       }
  73.       
  74.       override public function jouer() : *
  75.       {
  76.          mascotte.gotoAndStop(1);
  77.          mascotte.visible = true;
  78.          bonne = true;
  79.          score.score = 0;
  80.          current_question = 0;
  81.          _next_question();
  82.       }
  83.       
  84.       public function _repondre(param1:int) : void
  85.       {
  86.          var _loc2_:* = undefined;
  87.          if(timer_question.running)
  88.          {
  89.             return;
  90.          }
  91.          trace("_repondre " + param1 + " / " + DataSuperQuiz.reponses[current_question]);
  92.          _loc2_ = this["quizz" + String(current_question)];
  93.          if(DataSuperQuiz.reponses[current_question] == param1)
  94.          {
  95.             trace("reponse juste");
  96.             if(bonne)
  97.             {
  98.                score.score += 1;
  99.             }
  100.             bonne = true;
  101.             mascotte.gotoAndStop(2);
  102.             _loc2_.question.gotoAndStop(40);
  103.          }
  104.          else
  105.          {
  106.             trace("reponse fausse");
  107.             bonne = false;
  108.             if(secondechance)
  109.             {
  110.                mascotte.gotoAndStop(3);
  111.             }
  112.             else
  113.             {
  114.                mascotte.gotoAndStop(3);
  115.             }
  116.             _loc2_.question.gotoAndStop(80);
  117.          }
  118.          timer_question.addEventListener(TimerEvent.TIMER_COMPLETE,_next_question);
  119.          timer_question.start();
  120.       }
  121.       
  122.       public function _next_question(param1:TimerEvent = null) : *
  123.       {
  124.          var _loc2_:* = undefined;
  125.          trace(bonne + "-" + current_question + "-" + (DataSuperQuiz.reponses.length - 1));
  126.          if(bonne)
  127.          {
  128.             ++current_question;
  129.             secondechance = false;
  130.          }
  131.          else
  132.          {
  133.             secondechance = true;
  134.          }
  135.          mascotte.gotoAndStop(1);
  136.          if(current_question >= DataSuperQuiz.reponses.length)
  137.          {
  138.             finjeu();
  139.             return;
  140.          }
  141.          n_page.text = String(current_question);
  142.          _loc2_ = this["quizz" + String(current_question)];
  143.          hide_all_but(_loc2_);
  144.          _loc2_.question.gotoAndStop(1);
  145.          _loc2_.btn1.clicAction = _repondre;
  146.          _loc2_.btn2.clicAction = _repondre;
  147.          _loc2_.btn3.clicAction = _repondre;
  148.       }
  149.       
  150.       public function finjeu() : void
  151.       {
  152.          if(fin != null)
  153.          {
  154.             fin(score.score);
  155.          }
  156.          hide_all_but(page_resultat);
  157.          mascotte.visible = false;
  158.          if(score.score >= 9)
  159.          {
  160.             page_resultat.bravo1.points.text = score.score;
  161.             page_resultat.dommage.visible = false;
  162.             page_resultat.bravo1.visible = true;
  163.          }
  164.          else
  165.          {
  166.             page_resultat.dommage.points.text = score.score;
  167.             page_resultat.dommage.visible = true;
  168.             page_resultat.bravo1.visible = false;
  169.          }
  170.       }
  171.    }
  172. }
  173.